﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PraxisRent.Entities;

namespace PraxisRent.Repository
{
    public class MenuRepository:MasterRepository,IMenuRepository
    {

        //metodo para mostrar las pestañas generales del menu
        public List<MENU> GetAllFromMenu()
        {
            var query = from c in context.MENUs
                        where c.Tag == 1000 || c.Tag == 2000 || c.Tag == 3000 || c.Tag == 4000 || c.Tag == 4030 || c.Tag == 4060
                        select c;
            return query.ToList();
        }


        //metodo para avanzar a las sub pestañas del menu general
        public List<MENU> GetAllFromMenuByTag(int tag)
        {
            if (tag == 1000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1005 || c.Tag == 1010 || c.Tag == 1015 || c.Tag == 1020 || c.Tag == 1025 || c.Tag == 1030 || c.Tag == 1035 || c.Tag == 1040
                            select c;
                return query.ToList();
            }
            else if (tag == 2000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2005 || c.Tag == 2010 || c.Tag == 2015
                            select c;
                return query.ToList();
            }
            else if (tag == 3000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3005 || c.Tag == 3015 || c.Tag == 3020 || c.Tag == 3025
                            select c;
                return query.ToList();
            }
            else if (tag == 4000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4005
                            select c;
                return query.ToList();
            }
            else if (tag == 4030)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4035
                            select c;
                return query.ToList();
            }
            else if (tag == 4060)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4065
                            select c;
                return query.ToList();
            }
            else
            {
                var query = from c in context.MENUs
                            where c.Tag == null
                            select c;
                return query.ToList();
            }
        }

        
        //metodo para avanzar a los detalles de cada pestaña del menu
        public List<MENU> GetAllFromMenuByMantenimientoByTag(int tag)
        {
            if (tag == 1005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1006 || c.Tag == 1007 || c.Tag == 1008 || c.Tag == 1009
                            select c;
                return query.ToList();
            }
            else if (tag == 1010)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1011 || c.Tag == 1012 || c.Tag == 1013 || c.Tag == 1014
                            select c;
                return query.ToList();
            }
            else if (tag == 1015)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1016 || c.Tag == 1017 || c.Tag == 1018 || c.Tag == 1019
                            select c;
                return query.ToList();
            }
            else if (tag == 1020)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1021 || c.Tag == 1022 || c.Tag == 1023 || c.Tag == 1024
                            select c;
                return query.ToList();
            }
            else if (tag == 1025)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1026 || c.Tag == 1027 || c.Tag == 1028 || c.Tag == 1029
                            select c;
                return query.ToList();
            }
            else if (tag == 1030)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1031 || c.Tag == 1032 || c.Tag == 1033 || c.Tag == 1034
                            select c;
                return query.ToList();
            }
            else if (tag == 1035)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1036 || c.Tag == 1037 || c.Tag == 1038 || c.Tag == 1039
                            select c;
                return query.ToList();
            }
            else if (tag == 1040)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1041 || c.Tag == 1042 || c.Tag == 1043 || c.Tag == 1044
                            select c;
                return query.ToList();
            }
            else if (tag == 2005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2006 || c.Tag == 2007 || c.Tag == 2008 || c.Tag == 2009
                            select c;
                return query.ToList();
            }
            else if (tag == 2010)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2011 || c.Tag == 2012 || c.Tag == 2013 || c.Tag == 2014
                            select c;
                return query.ToList();
            }
            else if (tag == 2015)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2016 || c.Tag == 2017 || c.Tag == 2018 || c.Tag == 2019
                            select c;
                return query.ToList();
            }
            else if (tag == 3005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3006 || c.Tag == 3007 || c.Tag == 3008 || c.Tag == 3009 || c.Tag == 3010 || c.Tag == 3011 || c.Tag == 3012
                            select c;
                return query.ToList();
            }
            else if (tag == 3015)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3016 || c.Tag == 3017 || c.Tag == 3018
                            select c;
                return query.ToList();
            }
            else if (tag == 3020)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3021 || c.Tag == 3022 || c.Tag == 3023
                            select c;
                return query.ToList();
            }
            else if (tag == 3025)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3026 || c.Tag == 3027 || c.Tag == 3028
                            select c;
                return query.ToList();
            }
            else if (tag == 4005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4006 || c.Tag == 4007
                            select c;
                return query.ToList();
            }
            else if (tag == 4035)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4036 || c.Tag == 4037
                            select c;
                return query.ToList();
            }
            else if (tag == 4065)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4066 || c.Tag == 4067 || c.Tag == 4068
                            select c;
                return query.ToList();
            }
            else
            {
                var query = from c in context.MENUs
                            where c.Tag == null
                            select c;
                return query.ToList();
            }
        }


        //metodo para retroceder en la buskeda del menu
        public List<MENU> GetAllFromMenuByMantenimeintoByTagByReturn(int tag)
        {
            if (tag == 1006 || tag == 1007 || tag == 1008 || tag == 1009 || tag == 1011 || tag == 1012 || tag == 1013 || tag == 1014 ||
                tag == 1016 || tag == 1017 || tag == 1018 || tag == 1019 || tag == 1021 || tag == 1022 || tag == 1023 || tag == 1024 ||
                tag == 1026 || tag == 1027 || tag == 1028 || tag == 1029 || tag == 1031 || tag == 1032 || tag == 1033 || tag == 1034 ||
                tag == 1036 || tag == 1037 || tag == 1038 || tag == 1039 || tag == 1041 || tag == 1042 || tag == 1043 || tag == 1044)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1005 || c.Tag == 1010 || c.Tag == 1015 || c.Tag == 1020 || c.Tag == 1025 ||
                            c.Tag == 1030 || c.Tag == 1035 || c.Tag == 1040
                            select c;
                return query.ToList();
            }
            else if (tag == 2006 || tag == 2007 || tag == 2008 || tag == 2009 || tag == 2011 || tag == 2012 || tag == 2013 || tag == 2014 ||
                tag == 2016 || tag == 2017 || tag == 2018 || tag == 2019)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2005 || c.Tag == 2010 || c.Tag == 2015
                            select c;
                return query.ToList();
            }
            else if (tag == 3006 || tag == 3007 || tag == 3008 || tag == 3009 || tag == 3010 || tag == 3011 || tag == 3012 || tag == 3016 || tag == 3017 || tag == 3018 ||
                tag == 3021 || tag == 3022 || tag == 3023 || tag == 3026 || tag == 3027 || tag == 3028)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3005 || c.Tag == 3015 || c.Tag == 3020 || c.Tag == 3025
                            select c;
                return query.ToList();
            }
            else if (tag == 4006 || tag == 4007)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4005
                            select c;
                return query.ToList();
            }
            else if (tag == 4036 || tag == 4037)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4030
                            select c;
                return query.ToList();
            }
            else if (tag == 4066 || tag == 4067 || tag == 40068)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4065
                            select c;
                return query.ToList();
            }
            else if(tag>=1005 || tag <=1040 || tag>=2005 || tag<=2015 || tag>=3005 || tag<=3025 || tag>=4005 || tag<=4025 ||
                       tag>=4035 || tag <=4055 || tag>=4065 || tag<=4095)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1000 || c.Tag == 2000 || c.Tag == 3000 || c.Tag == 4000 || c.Tag == 4030 || c.Tag == 4060
                            select c;
                return query.ToList();
            }
            else
            {
                var query = from c in context.MENUs
                            where c.Tag == null
                            select c;
                return query.ToList();
            }
        }
    }
}
